﻿// -----------------------------
// Copyright © Kodi Studios 2011
// -----------------------------

using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Collections.Generic;

namespace Kodi.Picturethrill
{
    class NasaImageProvider : IImageProvider
    {
        static string nasaUrl = "http://apod.nasa.gov/apod";

        List<string> imageUrls = new List<string>();

        public NasaImageProvider()
        {
        }

        public IList<string> ImageUrls
        {
            get
            {
                if (this.imageUrls.Count == 0)
                {
                    // ExampleMatch: <a href="image/1112/PIA15138vestarocks.jpg"
                    imageUrls.Add(HtmlUtilities.GetImageUrl(nasaUrl, new Regex(@"\<a href\=\""(image[^\""]+)\""")));
                }
                return this.imageUrls;
            }
        }

        public string Name
        {
            get
            {
                return "Nasa";
            }
        }

        public string SiteName
        {
            get
            {
                return nasaUrl;
            }
        }
    }
}
